/*
 * Taras Boichenko, Kiev 2012
 * Calendar
 * Program which finds a day of week 
 */
          import java.util.*;
                  public class Calendar{
                   public static void main (String[] arg) {
                        Scanner in = new Scanner(System.in);
                        System.out.print ("Write day number :");
                               int day_number = in.nextInt();

                       if ((day_number<0) || (day_number>31)){
                            System.out.print ("Please input a day number from 1 to 31");
                            return;
              }
                            System.out.print ("Write month number:");
                                int month_number = in.nextInt();

                       if ((month_number<0) || (month_number>12)){
              
                            System.out.print ("Please input a month number from 1 to 12");
                            return;
              }
                            System.out.print ("Write year:");
                                int year_number = in.nextInt();

                       if (year_number<0){
              
                            System.out.print ("Please input a year number more than 0");
                             return;

              }          

                                int a = (14 - month_number) / 12;
                                int y = year_number - a;
                                int m = month_number + 12*a-2;

                                int DN = (7000+(day_number+y+y/4-y/100+y/400+(31*m)/12))%7;
                                    switch (DN){
          
                             case 0:
		                        System.out.print ("Sunday");
                                      break;
                             case 1:
		                     System.out.print ("Monday");
                                      break;
                             case 2:
		                     System.out.print ("Tuesday");
                                      break;
                             case 3: 
            	             System.out.print ("Wednesday");
                                      break;
                             case 4: 
            	             System.out.print ("Thursday");
                                      break;
                             case 5:  
       		                 System.out.print ("Friday");
                                      break;
                             case 6:
                             System.out.print ("Saturday");
                             break; 
           }
     }
}